import Vue from "vue";
import Router from "vue-router";
const _import = require("./_import_" + process.env.NODE_ENV);
// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router);

/* Layout */
import Layout from "../views/layout/Layout";

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  {
    path: "/login",
    name: "login",
    component: _import("login/index"),
    hidden: true
  },
  { path: "/404", component: _import("404"), hidden: true },

  {
    path: "/",
    component: Layout,
    redirect: "/home",
    // hidden: true,
    role: [1, 2, 3, 5],
    children: [
      {
        name: "home", //name字段放在children里 会在 Breadcrumb里显示 首页就在外面
        path: "home",
        meta: { title: "首页", path: "/home", icon: "fa fa-home" },
        component: _import("home/index")
      }
    ]
  },

  {
    path: "/user",
    component: Layout,
    redirect: "/user/index",
    role: [1],
    children: [
      {
        path: "index",
        name: "User",
        component: _import("user/index"),
        meta: { title: "账户管理", path: "/user/index", icon: "fa fa-user" }
      }
    ]
  },

  {
    path: "/user",
    component: Layout,
    hidden: true,
    meta: { title: "账户管理", path: "/user/index" },
    children: [
      {
        path: "details",
        component: _import("user/details"),
        name: "User",
        meta: { title: "用户详情", path: "/user/details" }
      }
    ]
  },

  {
    path: "/dataStock",
    component: Layout,
    redirect: "/dataStock/index",
    // hidden: true,
    role: [1, 2],
    children: [
      {
        path: "index",
        name: "DataStock",
        meta: {
          title: "数据库存",
          path: "/dataStock/index",
          icon: "fa fa-microchip"
        },
        component: _import("dataStock/index")
      }
    ]
  },

  {
    path: "/dataStock",
    component: Layout,
    redirect: "/dataStock/index",
    hidden: true,
    meta: { title: "数据库存", path: "/dataStock/index" },
    children: [
      {
        path: "file",
        name: "DataStock",
        meta: { title: "数据管理", path: "/dataStock/file" },
        component: _import("dataStock/file")
      }
    ]
  },

  {
    path: "/dataStock",
    component: Layout,
    redirect: "/dataStock/index",
    hidden: true,
    meta: { title: "数据库存", path: "/dataStock/index" },
    children: [
      {
        path: "details",
        name: "DataStock",
        meta: { title: "库存详情", path: "/dataStock/details" },
        component: _import("dataStock/details")
      }
    ]
  },

  {
    path: "/allocation",
    component: Layout,
    redirect: "/allocation/index",
    role: [1, 2],
    children: [
      {
        path: "index",
        name: "Allocation",
        component: _import("allocation/index"),
        meta: {
          title: "数据分配",
          path: "/allocation/index",
          icon: "fa fa-sticky-note"
        }
      }
    ]
  },

  {
    path: "/allocation",
    component: Layout,
    redirect: "/allocation/index",
    hidden: true,
    meta: { title: "数据批次", path: "/allocation/index" },
    children: [
      {
        path: "detail",
        name: "Allocation",
        component: _import("allocation/detail"),
        meta: {
          title: "数据分配",
          path: "/allocation/detail",
          icon: "fa fa-sticky-note"
        }
      }
    ]
  },

  {
    path: "/chart",
    component: Layout,
    redirect: "/chart/index",
    role: [1, 2, 3, 5],
    children: [
      {
        path: "index",
        name: "chart",
        component: _import("chart/index"),
        meta: {
          title: "数据报表",
          path: "/version/index",
          icon: "fa fa-bar-chart"
        }
      }
    ]
  },

  {
    path: "/datapush",
    component: Layout,
    redirect: "/datapush/index",
    role: [1, 3],
    meta: { title: "转化推送", path: "/datapush/index", icon: "fa fa-recycle" },
    children: [
      {
        path: "index",
        name: "datapush",
        component: _import("datapush/index"),
        meta: {
          title: "转化数据",
          path: "/datapush/index",
          icon: "fa fa-circle-o"
        }
      },
      {
        path: "pushed",
        name: "pushed",
        component: _import("datapush/pushed"),
        meta: {
          title: "已推数据",
          path: "/datapush/pushed",
          icon: "fa fa-circle-o"
        }
      },
      {
        path: "datasearch",
        name: "datasearch",
        component: _import("datapush/pushSearch"),
        meta: {
          title: "数据反查",
          path: "/datapush/datasearch",
          icon: "fa fa-circle-o"
        }
      },
      /* 下面三个是特殊情况针对上级路由 设置 - 面包屑导航 */
      {
        path: "detail",
        name: "datapush",
        component: _import("datapush/detail"),
        hidden: true,
        meta: {
          title: "数据详情",
          path: "/datapush/detail",
          icon: "fa fa-circle-o"
        }
      },
      {
        path: "detail-t",
        name: "pushed",
        component: _import("datapush/detail"),
        hidden: true,
        meta: {
          title: "数据详情",
          path: "/datapush/detail-t",
          icon: "fa fa-circle-o"
        }
      },
      {
        path: "detail-s",
        name: "pushed",
        component: _import("datapush/detail"),
        hidden: true,
        meta: {
          title: "数据详情",
          path: "/datapush/detail-s",
          icon: "fa fa-circle-o"
        }
      }
    ]
  },

  {
    path: "/pushed",
    component: Layout,
    redirect: "/pushed/waitList",
    meta: { title: "已推数据", path: "/datapush/pushed" },
    hidden: true,
    children: [
      {
        path: "pushedlist",
        name: "pushed",
        component: _import("datapush/pushedList"),
        meta: {
          title: "批次数据列表",
          path: "/pushed/pushedlist",
          icon: "fa fa-download"
        }
      },
      {
        path: "waitList",
        name: "pushed",
        component: _import("datapush/waitlist"),
        meta: {
          title: "待转列表",
          path: "/pushed/waitList",
          icon: "fa fa-download"
        }
      }
    ]
  },

  {
    path: "/seni",
    component: Layout,
    redirect: "/seni/index",
    role: [7],
    children: [
      {
        path: "index",
        name: "seni",
        component: _import("seniCustomer/index"),
        meta: { title: "工作台", path: "/seni/index", icon: "fa fa-fax" }
      }
    ]
  },

  {
    path: "/search",
    component: Layout,
    redirect: "/search/index",
    role: [7],
    children: [
      {
        path: "index",
        name: "search",
        component: _import("search/index"),
        meta: { title: "数据查询", path: "/search/index", icon: "fa fa-search" }
      }
    ]
  },

  {
    path: "/version",
    component: Layout,
    redirect: "/version/index",
    role: [1],
    children: [
      {
        path: "index",
        name: "version",
        component: _import("version/index"),
        meta: {
          title: "版本管理",
          path: "/version/index",
          icon: "fa fa-download"
        }
      }
    ]
  },

  { path: "*", redirect: "/404", hidden: true }
];

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
});
